package com.itown.expo.controller;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.springframework.web.servlet.ModelAndView;

import webframe.common.helper.ControllerHelper;

import com.itown.expo.controller.base.MyBaseCommandController;
import com.itown.expo.model.EpidemicNotify;

public class EpidemicNotifySearchController extends MyBaseCommandController {
	private static Order[] orders = new Order[] { Order.desc("id") };

	@Override
	protected ModelAndView handleInner(HttpServletRequest request,
			HttpServletResponse response, Object command) {
		EpidemicNotify cepidemicNotify = (EpidemicNotify) command;

		DetachedCriteria criteria = DetachedCriteria
				.forClass(EpidemicNotify.class);

		ControllerHelper.addEqualRestrictions(criteria, "id", cepidemicNotify
				.getId());
		ControllerHelper.addLikeRestrictions(criteria, "name", cepidemicNotify
				.getName());

		ControllerHelper.addEqualRestrictions(criteria, "countryCode",
				cepidemicNotify.getCountryCode());
		ControllerHelper.addEqualRestrictions(criteria, "kind", cepidemicNotify
				.getKind());
		ControllerHelper.addEqualRestrictions(criteria, "situationCode",
				cepidemicNotify.getSituationCode());

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("page", ControllerHelper.queryPagination(request, orders,
				criteria));
		map.put("cepidemicNotify", cepidemicNotify);
		return new ModelAndView("EpidemicNotifyList.jsp", "map", map);
	}
}
